package com.mine.distinctionteam.ui.businessman;

import android.os.Handler;


import com.mine.distinctionteam.base.IView;
import com.mine.distinctionteam.bean.businessman.BusinessmanBean;

import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;


/**
 *
 */
public class BusinessmanPresenter implements BusinessmanContract.Presenter {
    private BusinessmanContract.View view;
    private BusinessmanContract.Modle modle;

    public BusinessmanPresenter(BusinessmanContract.View view){
        this.view=view;
        modle=new BusinessmanModle();
    }
    @Override
    public void getBusinessman(Map<String, String> map) {
        modle.getBusinessman(map, new Callback<BusinessmanBean>() {
            @Override
            public void onResponse(Call<BusinessmanBean> call, Response<BusinessmanBean> response) {
                final BusinessmanBean bean=response.body();
                Handler handler=new Handler();
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getBusinessmanSucess(bean);
                    }
                });
            }

            @Override
            public void onFailure(Call<BusinessmanBean> call, Throwable t) {
                view.getBusinessmanFail("加载失败");
            }
        });

    }

    @Override
    public void detachView() {

    }

    @Override
    public void attachView(IView view) {

    }
}
